/**
 * Created by benli on 1/19/16.
 */
function openDialog(url,title,width,height){
    layer.open({
                   type: 2,
                   title:title,
                   area: [width+'px',height+"px"],
                   fix: false, //不固定
                   maxmin: false,
                   shade:0.6,
                   content: url
               });
}

function serializeForm(form){
    var values = {};
    $.each($(form).serializeArray(),function(i,o){
        values[o.name]= o.value;
    })
    return values;
}

function cancelOperation(){
    var index = parent.layer.getFrameIndex(window.name);
    if(index == undefined) {
        window.history.back(-1);
        return false;
    } else {
        parent.layer.close(index);
    }
}

String.prototype.replaceAll = function (str1,str2){
    var str = this;
    var result = str.replace(eval("/"+str1+"/gi"),str2);
    return result;
}

//jQuery加载后自动调用pageInit()方法
$(function(){
    if(typeof pageInit == "function"){
        pageInit();
    }
})